﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;


public partial class guangli : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //private void getcom(int i)
    //{
    //    using (DataClassesDataContext ds = new DataClassesDataContext())
    //    {
    //        var rd1 = from q in ds.admin
    //                  where q.Name == TextBox5.Text.Trim().ToString()
    //                  where q.PWD == TextBox6.Text.Trim().ToString()
    //                  select q;
    //        if (rd1 != null)
    //        {
    //            Session["user"] = TextBox5.Text;

    //            Page.Response.Redirect("manage/admin.aspx");
    //        }
    //        else
    //        {
    //            Response.Write("<script>alert('用户名或密码错误！')</script>");
    //            //Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

    //        }
    //    }
    //}

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        HttpCookieCollection checkCode = Request.Cookies;
        string a = TextBox7.Text;
        string b = checkCode["CheckCode"].Value;
        if (TextBox5.Text == "" || TextBox7.Text == "")
        {
            Response.Write("<script>alert('请输入完整！')</script>");
            Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        }
        //else if (!a.Equals(b, StringComparison.OrdinalIgnoreCase))
        //{
        //    Response.Write("<script>alert('验证码有误！')</script>");
        //    Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        //}
        else
        {
            using (DataClassesDataContext ds = new DataClassesDataContext())
            {
                var rd1 = from q in ds.admin
                          where q.Name == TextBox5.Text.Trim().ToString()
                          where q.PWD == TextBox6.Text.Trim().ToString()
                          select q;
                if (rd1 != null)
                {
                    Session["user"] = TextBox5.Text;

                    Page.Response.Redirect("manage/admin.aspx");
                }
                else
                {
                    Response.Write("<script>alert('用户名或密码错误！')</script>");
                    //Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

                }
            }

        }


    }

}